// <editor-fold defaultstate="collapsed" desc="GNU GPLv3 Header">
/*
 * File:   main.c
 *
 * Copyright (C) 2013 Robert Antoni Buj Gelonch <rbuj@uoc.edu>
 * Copyright (C) 2013 David Megias Jimenez <dmegias@uoc.edu>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Created on September 5, 2013, 6:39 PM
 */
// </editor-fold>

#include <stdio.h>
#include <stdlib.h>
#include "AlawEncoder.h"
#include "AlawDecoder.h"
#include "UlawEncoder.h"
#include "UlawDecoder.h"

/*
 * 
 */
int main(int argc, char** argv) {
    short int sample = -5, result;
    char compressed;

    printf("> Alaw Test\n");
    printf("Original   : 0x%04hx (%i)\n", sample, sample);
    AlawEncode(&sample, &compressed);
    printf("Compressed :   0x%02hhx\n", compressed);
    AlawDecode(&compressed, &result);
    printf("Expanded   : 0x%04hx (%i)\n", result, result);
    printf("\n");

    printf("> Alaw Transmission Test\n");
    printf("Original   : 0x%04hx (%i)\n", sample, sample);
    AlawEncodeTransmission(&sample, &compressed);
    printf("Compressed :   0x%02hhx\n", compressed);
    AlawDecodeTransmission(&compressed, &result);
    printf("Expanded   : 0x%04hx (%i)\n", result, result);
    printf("\n");

    sample = 1024;

    printf("> Ulaw Test\n");
    printf("Original   : 0x%04hx (%i)\n", sample, sample);
    UlawEncode(&sample, &compressed);
    printf("Compressed :   0x%02hhx\n", compressed);
    UlawDecode(&compressed, &result);
    printf("Expanded   : 0x%04hx (%i)\n", result, result);
    printf("\n");

    printf("> Alaw Transmission Test\n");
    printf("Original   : 0x%04hx (%i)\n", sample, sample);
    UlawEncodeTransmission(&sample, &compressed);
    printf("Compressed :   0x%02hhx\n", compressed);
    UlawDecodeTransmission(&compressed, &result);
    printf("Expanded   : 0x%04hx (%i)\n", result, result);
    printf("\n");
    return (EXIT_SUCCESS);
}

